<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('样品登记列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>样品名称：</label>
                                <input type="text" name="sampleName"/>
                            </li>
                            <li>
                                <label>公司名称：</label>
                                <input type="text" name="companyName"/>
                            </li>
                            <li>
                                <label>联系人：</label>
                                <input type="text" name="contactPerson"/>
                            </li>
                            <li>
                                <label>联系电话：</label>
                                <input type="text" name="phone"/>
                            </li>
                            <li>
                                <label>邮寄地址：</label>
                                <input type="text" name="address"/>
                            </li>
                            <li>
                                <label>邮寄日期：</label>
                                <input type="text" class="time-input" placeholder="请选择邮寄日期" name="sendDate"/>
                            </li>
                            <li>
                                <label>签收日期：</label>
                                <input type="text" class="time-input" placeholder="请选择签收日期" name="receiveDate"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="order:sampleregistration:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="order:sampleregistration:edit">-->
                    <!--<i class="fa fa-edit"></i> 修改-->
                <!--</a>-->
                <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="order:sampleregistration:remove">-->
                    <!--<i class="fa fa-remove"></i> 删除-->
                <!--</a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="order:sampleregistration:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('order:sampleregistration:edit')}]];
        var removeFlag = [[${@permission.hasPermi('order:sampleregistration:remove')}]];
        var prefix = ctx + "order/sampleregistration";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "样品登记",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'sampleName',
                    title: '样品名称'
                },
                {
                    field: 'companyName',
                    title: '公司名称'
                },
                {
                    field: 'contactPerson',
                    title: '联系人'
                },
                {
                    field: 'phone',
                    title: '联系电话'
                },
                {
                    field: 'address',
                    title: '邮寄地址'
                },
                {
                    field: 'expressName',
                    title: '物流快递'
                },
                {
                    field: 'expressNo',
                    title: '快递单号'
                },
                {
                    field: 'logisticsFee',
                    title: '邮寄费用'
                },
                {
                    field: 'payer',
                    title: '物流付款人'
                },
                {
                    field: 'sendDate',
                    title: '邮寄日期'
                },
                {
                    field: 'receiveDate',
                    title: '签收日期'
                },
                {
                    field: 'feedback',
                    title: '签收反馈'
                },
                {
                    field: 'transFlag',
                    title: '转化标识'
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.transFlag == 0){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="transCustomer(\'' + row.id + '\')"><i class="fa fa-ticket"></i>转化为客户</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');

                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });


        function transCustomer(id){
            $.modal.confirm("确认要把当前用户的数据同步到客户档案吗？", function() {
                let url = prefix + "/transCustomer";
                let data = { "id": id};
                $.operate.submit(url, "post", "json", data);
            });
        }
    </script>
</body>
</html>